package com.xuecheng.content.domain.feignclient.fallback;

import com.xuecheng.content.domain.feignclient.SearchServiceClient;
import com.xuecheng.content.domain.model.dto.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-09-01  13:48
 */
@Slf4j
@Component
public class SearchServiceClientFallbackFactory implements FallbackFactory<SearchServiceClient> {
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean addIndex(CourseIndex courseIndex) {
                log.error("调用搜索服务保存es索引发生熔断，异常信息:{}", throwable.toString(), throwable);
                return null;
            }
        };
    }
}
